package com.enation.app.javashop.core.client.fallback.member;

import com.enation.app.javashop.core.client.feignimpl.member.ShopRoleClientFeignImpl;
import com.enation.app.javashop.core.handler.BaseFallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Map;

/**
 * 角色的权限熔断器fallback factory
 * @author kingapex
 * @version 1.0
 * @data 2022/5/28 14:27
 **/
@Component
public class ShopRoleClientFallbackFactory extends BaseFallbackFactory<ShopRoleClientFeignImpl> {
    @Override
    protected ShopRoleClientFeignImpl fallback() {
        return new ShopRoleClientFallback();
    }

    /**
     * 角色的权限熔断器
     *
     * @author zh
     * @version v7.0
     * @date 18/9/27 下午4:50
     * @since v7.0
     */
    @Component
    public static class ShopRoleClientFallback implements ShopRoleClientFeignImpl {

        private final Logger logger = LoggerFactory.getLogger(getClass());

        @Override
        public Map<String, List<String>> getRoleMap(Long sellerId) {
            logger.error("获取店铺ID为" + sellerId + "的店铺的角色权限错误");
            return null;
        }
    }
}
